<?php
/**
 * Each engineer has a duty to keep the code elegant
 * Created by wolffy.
 * Author @wolffy<13750088090@sina.cn>
 * Date: 2018/9/3
 * Time: 00:34
 */
namespace App\Http\Controllers\Api\V1_0_0;

use Illuminate\Http\Request;
use App\Services\MemberUpgradeService;

class MemberUpgradeController extends BaseController
{
    protected $memberUpgradeService;

    public function __construct(MemberUpgradeService $memberUpgradeService)
    {
        parent::__construct();
        $this->memberUpgradeService = $memberUpgradeService;
    }

    /**
     * 支付升级代言人
     */
    public function memberUpgradePay(Request $request)
    {
        if (empty($request->pay_way)) {
            return $this->responseJson(422);
        }
        if ('wxpay' === $request->pay_way) {
            return $this->memberUpgradeService->wxpayOrder($this->user['user_id'], $this->user['level'], $request->ip());
        }
        if ('alipay' === $request->pay_way) {
            return $this->memberUpgradeService->alipayOrder($this->user['user_id'], $this->user['level']);
        }
        return $this->responseJson(400);
    }

}